// JavaScript Document
$(function(){
	$('#photoList ul').masonry({
		itemSelector : '#photoList ul li',
		isAnimated: true,
		columnWidth: 10,
	});
	
	//---------------------------------------*****
	//=====主選單
	//---------------------------------------*****
	$("#nav ul li").hover(function(e){
		var N = $(this).index();
		TweenLite.to($("#nav ul li a").eq(N), 0.5, {css:{backgroundPosition:"top"},ease:Quint.easeOut});
	},function(e){
		TweenLite.to($("#nav ul li a"), 0.5, {css:{backgroundPosition:"bottom"},ease:Quint.easeOut});
	});
	//---------------------------------------*****
	//=====我的收藏
	//---------------------------------------*****
	$("#myTag").hover(function(){
		TweenLite.to($("#myTag a"), 0.5, {css:{backgroundPosition:"top"},ease:Quint.easeOut});
	},function(){
		TweenLite.to($("#myTag a"), 0.5, {css:{backgroundPosition:"bottom"},ease:Quint.easeOut});
	});
	//---------------------------------------*****
	//=====登入會員，FB及Email登入
	//---------------------------------------*****
	$(".logBtnFb").click(function(e){
		e.preventDefault();
		BrushBlack();
	});
	$(".logBtnEmail").click(function(e){
		e.preventDefault();
		BrushBlack();
	});
	
	$(".btnClose").click(function(e){
		CloseLoginFrom();
		e.preventDefault();
	});
	
	$("#brushBlack").click(function(e){
		CloseLoginFrom();
		e.preventDefault();
		TweenLite.to($("#pleaseLogIn"), 0, {css:{display:"none"}});
	});
	
	$(".btn_Forget").click(function(e){
		TweenLite.to($("#logInTitle a"), 0.5, {css:{left:-95},ease:Quint.easeOut});
		TweenLite.to($("#enterForm"), 0.5, {css:{left:-300},ease:Quint.easeOut});
		TweenLite.to($("#forgetForm"), 0.5, {css:{left:0},ease:Quint.easeOut});
		e.preventDefault();
	});
	
	$(".btn_delForget").click(function(e){
		TweenLite.to($("#logInTitle a"), 0.5, {css:{left:0},ease:Quint.easeOut});
		TweenLite.to($("#enterForm"), 0.5, {css:{left:0},ease:Quint.easeOut});
		TweenLite.to($("#forgetForm"), 0.5, {css:{left:300},ease:Quint.easeOut});
		e.preventDefault();
	});
	
	function CloseLoginFrom(){
		TweenLite.to($("#brushBlack"), 0.5, {alpha:0,ease:Quint.easeOut,onComplete:function(){
			TweenLite.to($("#brushBlack"), 0, {css:{display:"none"}});
		}});
		TweenLite.to($("#logInBox"), 0, {alpha:0,ease:Quint.easeOut,onComplete:function(){
			TweenLite.to($("#logInBox"), 0, {css:{display:"none"}});
		}});
		TweenLite.to($("#logInTitle a"), 0.5, {css:{left:0},ease:Quint.easeOut});
		TweenLite.to($("#enterForm"), 0.5, {css:{left:0},ease:Quint.easeOut});
		TweenLite.to($("#forgetForm"), 0.5, {css:{left:300},ease:Quint.easeOut});
	}
	
	function BrushBlack(){
		TweenLite.to($("#pleaseLogIn"), 0, {css:{display:"none"}});
		TweenLite.to($("#logInBox"), 0, {css:{display:"block"},onComplete:function(){
			TweenLite.to($("#logInBox"), 0.5, {alpha:1,ease:Quint.easeOut});
		}});
		TweenLite.to($("#brushBlack"), 0, {css:{display:"block"},onComplete:function(){
			TweenLite.to($("#brushBlack"), 0.5, {alpha:0.85,ease:Quint.easeOut});
		}});
	}
	//---------------------------------------*****
	//=====編輯帳號，創造我的俬迷本，上傳我的俬分享
	//---------------------------------------*****
	//目前三個視窗都設定display:none全都放在html的滿上面的
	
	//---------------------------------------*****
	//=====PhotoList member按鍵操作
	//---------------------------------------*****
	//初始值先將三顆按鈕藏起
	TweenLite.to($(".btn_memberLike"), 0, {css:{bottom:30,alpha:0}});
	TweenLite.to($(".btn_collect"), 0, {css:{bottom:30,alpha:0}});
	TweenLite.to($(".btn_sharefb"), 0, {css:{bottom:30,alpha:0}});
	
	var N = 0;
	$("#photoList ul li").hover(function(){
		N = $(this).index();
		TweenLite.to($(".btn_memberLike").eq(N), 0.3, {css:{bottom:60,alpha:1},ease:Quint.easeOut});
		TweenLite.to($(".btn_collect").eq(N), 0.3, {css:{bottom:60,alpha:1},ease:Quint.easeOut});
		TweenLite.to($(".btn_sharefb").eq(N), 0.3, {css:{bottom:60,alpha:1},ease:Quint.easeOut});
		TweenLite.to($("#photoList ul li").eq(N).find("span"), 0.3, {css:{alpha:1},ease:Quint.easeOut});
	},function(){
		TweenLite.to($(".btn_memberLike"), 0.3, {css:{bottom:30,alpha:0},ease:Quint.easeOut});
		TweenLite.to($(".btn_collect"), 0.3, {css:{bottom:30,alpha:0},ease:Quint.easeOut});
		TweenLite.to($(".btn_sharefb"), 0.3, {css:{bottom:30,alpha:0},ease:Quint.easeOut});
		TweenLite.to($("#photoList ul li").find("span"), 0.3, {css:{alpha:0},ease:Quint.easeOut});
	});
	
	//未登入會員時的提示視意
	$("#photoList ul li").click(function(e){
//		TweenLite.to($("#brushBlack"), 0, {css:{display:"block"},onComplete:function(){
//			TweenLite.to($("#brushBlack"), 0.5, {alpha:0.85,ease:Quint.easeOut});
//		}});
//			TweenLite.to($("#pleaseLogIn"), 0, {css:{display:"block"}});
	});

	$(".btn_memberLike").hover(function(){
		TweenLite.to($(".btn_memberLike").eq(N), 0.5, {css:{backgroundPosition:"top left"},ease:Quint.easeOut});
	},function(){
		TweenLite.to($(".btn_memberLike").eq(N), 0.5, {css:{backgroundPosition:"bottom left"},ease:Quint.easeOut});
	});
	
	$(".btn_collect").hover(function(){
		TweenLite.to($(".btn_collect").eq(N), 0.5, {css:{backgroundPosition:"top left"},ease:Quint.easeOut});
	},function(){
		TweenLite.to($(".btn_collect").eq(N), 0.5, {css:{backgroundPosition:"bottom left"},ease:Quint.easeOut});
	});
	
	$(".btn_sharefb").hover(function(){
		TweenLite.to($(".btn_sharefb").eq(N), 0.5, {css:{backgroundPosition:"top left"},ease:Quint.easeOut});
	},function(){
		TweenLite.to($(".btn_sharefb").eq(N), 0.5, {css:{backgroundPosition:"bottom left"},ease:Quint.easeOut});
	});
	
//  這裡只是示意當按了喜歡之後的樣子~~詳細因為要記錄每一個單獨的再麻煩程式大哥嘍謝謝~目前只有一個記錄~所以如果有東西被按了，另一個會要按兩次才能改回ML的布林
	var ML = true;
	$(".btn_memberLike").click(function(e){
		console.log(N);
		if(ML == true){
			TweenLite.to($(".btn_memberLike").eq(N), 0, {css:{width:80,textIndent:0,backgroundPosition:"top left"}});
			TweenLite.to($(".btn_collect").eq(N), 0.3, {css:{marginLeft:125},ease:Quint.easeOut});
			TweenLite.to($(".btn_sharefb").eq(N), 0.3, {css:{marginLeft:160},ease:Quint.easeOut});
			ML = false;
		}else{
			TweenLite.to($(".btn_memberLike").eq(N), 0, {css:{width:0,textIndent:-9999}});
			TweenLite.to($(".btn_collect").eq(N), 0.3, {css:{marginLeft:45},ease:Quint.easeOut});
			TweenLite.to($(".btn_sharefb").eq(N), 0.3, {css:{marginLeft:80},ease:Quint.easeOut});
			ML = true;
		}
		e.preventDefault();
	});

	 

});




